<!doctype html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:c="http://www.w3.org/1999/XSL/Transform">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>文章 - 502工作室管理系统</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
    <link rel="apple-touch-icon-precomposed" href="images/icon/icon.png">
    <link rel="shortcut icon" href="images/icon/favicon.ico">
    <link rel="stylesheet" type="text/css" href="css/pagination.css" media="screen">
    <script src="js/jquery-2.1.4.min.js"></script>
    <script src="js/jquery.pagination.js"></script>
    <!--[if gte IE 9]>
    <script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="js/html5shiv.min.js" type="text/javascript"></script>
    <script src="js/respond.min.js" type="text/javascript"></script>
    <script src="js/selectivizr-min.js" type="text/javascript"></script>
    <![endif]-->
    <!--[if lt IE 9]>
    <script>window.location.href = 'upgrade-browser.html';</script>
    <![endif]-->
</head>

<body class="user-select">
<section class="container-fluid">
    <header>
        <nav class="navbar navbar-default navbar-fixed-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                            data-target="#bs-example-navbar-collapse-1" aria-expanded="false"><span
                            class="sr-only">切换导航</span> <span class="icon-bar"></span> <span class="icon-bar"></span>
                        <span class="icon-bar"></span></button>
                    <a class="navbar-brand" href="#">502</a></div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">消息 <span class="badge">1</span></a></li>
                        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" role="button"
                                                aria-haspopup="true" aria-expanded="false">admin <span
                                class="caret"></span></a>
                            <ul class="dropdown-menu dropdown-menu-left">
                                <li><a title="查看或修改个人信息" data-toggle="modal" data-target="#seeUserInfo">个人信息</a></li>
                                <li><a title="查看您的登录记录" data-toggle="modal" data-target="#seeUserLoginlog">登录记录</a></li>
                            </ul>
                        </li>
                        <li><a href="/geekdaily/logout" onClick="if(!confirm('是否确认退出？'))return false;">退出登录</a></li>
                        <li><a data-toggle="modal" data-target="#WeChat">小程序</a></li>
                    </ul>
                    <form action="" method="" class="navbar-form navbar-right" role="search">
                        <div class="input-group">
                            <input type="text" class="form-control" autocomplete="off" placeholder="键入关键字搜索"
                                   maxlength="15">
                            <span class="input-group-btn">
              <button class="btn btn-default" type="button">搜索</button>
              </span></div>
                    </form>
                </div>
            </div>
        </nav>
    </header>
    <div class="row">
        <aside class="col-sm-3 col-md-2 col-lg-2 sidebar">
            <ul class="nav nav-sidebar">
                <li><a href="/geekdaily/index">报告</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li class="active"><a href="/geekdaily/webArticle">文章</a></li>
                <li><a data-toggle="tooltip" data-placement="top" title="暂未开放该功能">公告</a></li>
                <li><a data-toggle="tooltip" data-placement="top" title="暂未开放该功能">评论</a></li>
                <li><a data-toggle="tooltip" data-placement="top" title="网站暂无留言功能">留言</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a data-toggle="tooltip" data-placement="top" title="暂未开放该功能">栏目</a></li>
                <li><a data-toggle="tooltip" data-placement="top" title="暂未开放该功能">其他</a>
                <!--<li><a class="dropdown-toggle" id="otherMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">其他</a>-->
                    <ul class="dropdown-menu" aria-labelledby="otherMenu">
                        <li><a href="flink.html">友情链接</a></li>
                        <li><a href="loginlog.html">访问记录</a></li>
                    </ul>
                </li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a data-toggle="tooltip" data-placement="top" title="暂未开放该功能">用户</a>
                <!--<li><a class="dropdown-toggle" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">用户</a>-->
                    <ul class="dropdown-menu" aria-labelledby="userMenu">
                        <li><a href="#">管理用户组</a></li>
                        <li><a href="manage-user.html">管理用户</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="loginlog.html">管理登录日志</a></li>
                    </ul>
                </li>
                <li><a data-toggle="tooltip" data-placement="top" title="暂未开放该功能">设置</a>
                <!--<li><a class="dropdown-toggle" id="settingMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">设置</a>-->
                    <ul class="dropdown-menu" aria-labelledby="settingMenu">
                        <li><a href="setting.html">基本设置</a></li>
                        <li><a href="readset.html">用户设置</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">安全配置</a></li>
                        <li role="separator" class="divider"></li>
                        <li class="disabled"><a>扩展菜单</a></li>
                    </ul>
                </li>
            </ul>
        </aside>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
            <form action="/Article/checkAll" method="post">
                <h1 class="page-header">操作</h1>
                <ol class="breadcrumb">
                    <li><a href="/geekdaily/webAddArticle">增加文章</a></li>
                </ol>
                <h1 class="page-header">管理 </h1>  <!--<span class="badge">7</span>-->
                <div id= "article_div" class="table-responsive">
                    <table id="table" class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th><span class="glyphicon glyphicon-th-large"></span> <span class="visible-lg">选择</span>
                            </th>
                            <th><span class="glyphicon glyphicon-header"></span> <span class="visible-lg">贡献者</span>
                            </th>
                            <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">标题</span></th>
                            <th><span class="glyphicon glyphicon-list"></span> <span class="visible-lg">描述</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-link"></span> <span
                                    class="visible-lg">文章链接</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-link"></span> <span
                                    class="visible-lg">图片链接</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-star"></span> <span
                                    class="visible-lg">点赞</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-comment"></span> <span
                                    class="visible-lg">评论</span></th>
                            <th class="hidden-sm"><span class="glyphicon glyphicon-facetime-video"></span> <span
                                    class="visible-lg">浏览量</span></th>
                            <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">日期</span></th>
                            <th><span class="glyphicon glyphicon-pencil"></span> <span class="visible-lg">操作</span></th>
                        </tr>
                        </thead>
                        <div id="tbody" th:fragment="fragment">
                        <tr id="articles" th:each="article : ${articleList}">
                            <td><input type="checkbox" class="input-control" name="checkbox[]" value=""/></td>
                            <td th:if="${article.user != null}" th:text="${article.user.userName}"></td>
                            <td th:if="${article.user == null}" th:text="匿名用户"></td>
                            <td style="max-width: 200px" th:text="${article.title}"></td>
                            <td style="max-width: 200px" th:text="${article.des}"></td>
                            <td style="max-width: 200px; text-overflow: ellipsis;overflow:hidden;">
                                <a th:href="${article.link}" target="_blank" th:text="${article.link}"/>
                            </td>
                            <td style="max-width: 200px; text-overflow: ellipsis;overflow:hidden;">
                                <a th:href="${article.imgUrl}" target="_blank" th:text="${article.imgUrl}"/>
                            </td>
                            <td class="hidden-sm" th:text="${article.stars}"></td>
                            <td class="hidden-sm" th:text="${article.comments}"></td>
                            <td class="hidden-sm" th:text="${article.views}"></td>
                            <td th:text="${#dates.format(article.date, 'yyyy-MM-dd HH:mm:ss')}">2015-12-03</td>
                            <td th:switch="${article.reviewStatus}">
                                <a th:onclick="'javascript:editArticle(\''+${article.articleId}+'\')'">修改</a>
                                <a th:onclick="'javascript:deleteArticle(\''+${article.articleId}+'\')'">删除</a>
                                <a th:case="1" th:onclick="'javascript:reviewArticle(\''+${article.articleId}+'\')'">已通过</a>
                                <a th:case="-1" th:onclick="'javascript:reviewArticle(\''+${article.articleId}+'\')'">未通过</a>
                                <a th:case="*" th:onclick="'javascript:reviewArticle(\''+${article.articleId}+'\')'">审核中</a>
                            </td>
                        </tr>
                        </div>
                    </table>
                </div>
                <footer class="message_footer">
                    <nav>
                        <div class="btn-toolbar operation" role="toolbar">
                            <div class="btn-group" role="group"><a class="btn btn-default" onClick="select()">全选</a> <a
                                    class="btn btn-default" onClick="reverse()">反选</a> <a class="btn btn-default"
                                                                                          onClick="noselect()">不选</a>
                            </div>
                            <div class="btn-group" role="group">
                                <button type="button" disabled="value" class="btn btn-default" data-toggle="tooltip"
                                        data-placement="bottom" title="删除全部选中" name="checkbox_delete">删除
                                </button>
                            </div>
                        </div>
                        <div class="pagination pagenav">
                            <ul class="m-style pagination" id="p3"></ul>
                        </div>
                    </nav>
                </footer>
            </form>
        </div>
    </div>
</section>
<!--个人信息模态框-->
<div class="modal fade" id="seeUserInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <form action="" method="post">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">个人信息</h4>
                </div>
                <div class="modal-body">
                    <table class="table" style="margin-bottom:0px;">
                        <thead>
                        <tr></tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td wdith="20%">姓名:</td>
                            <td width="80%"><input type="text" value="王雨" class="form-control" name="truename"
                                                   maxlength="10" autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">用户名:</td>
                            <td width="80%"><input type="text" value="admin" class="form-control" name="username"
                                                   maxlength="10" autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">电话:</td>
                            <td width="80%"><input type="text" value="18538078281" class="form-control" name="usertel"
                                                   maxlength="13" autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">旧密码:</td>
                            <td width="80%"><input type="password" class="form-control" name="old_password"
                                                   maxlength="18" autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">新密码:</td>
                            <td width="80%"><input type="password" class="form-control" name="password" maxlength="18"
                                                   autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">确认密码:</td>
                            <td width="80%"><input type="password" class="form-control" name="new_password"
                                                   maxlength="18" autocomplete="off"/></td>
                        </tr>
                        </tbody>
                        <tfoot>
                        <tr></tr>
                        </tfoot>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!--个人登录记录模态框-->
<div class="modal fade" id="seeUserLoginlog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">登录记录</h4>
            </div>
            <div class="modal-body">
                <table class="table" style="margin-bottom:0px;">
                    <thead>
                    <tr>
                        <th>登录IP</th>
                        <th>登录时间</th>
                        <th>状态</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>::1:55570</td>
                        <td>2016-01-08 15:50:28</td>
                        <td>成功</td>
                    </tr>
                    <tr>
                        <td>::1:64377</td>
                        <td>2016-01-08 10:27:44</td>
                        <td>成功</td>
                    </tr>
                    <tr>
                        <td>::1:64027</td>
                        <td>2016-01-08 10:19:25</td>
                        <td>成功</td>
                    </tr>
                    <tr>
                        <td>::1:57081</td>
                        <td>2016-01-06 10:35:12</td>
                        <td>成功</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">朕已阅</button>
            </div>
        </div>
    </div>
</div>
<!--微信二维码模态框-->
<div class="modal fade user-select" id="WeChat" tabindex="-1" role="dialog" aria-labelledby="WeChatModalLabel">
    <div class="modal-dialog" role="document" style="margin-top:120px;max-width:280px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="WeChatModalLabel" style="cursor:default;">微信扫一扫</h4>
            </div>
            <div class="modal-body" style="text-align:center"><img src="images/weixin.jpg" alt=""
                                                                   style="cursor:pointer"/></div>
        </div>
    </div>
</div>
<!--提示模态框-->
<div class="modal fade user-select" id="areDeveloping" tabindex="-1" role="dialog"
     aria-labelledby="areDevelopingModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="areDevelopingModalLabel" style="cursor:default;">该功能正在日以继夜的开发中…</h4>
            </div>
            <div class="modal-body"><img src="images/baoman/baoman_01.gif" alt="深思熟虑"/>
                <p style="padding:15px 15px 15px 100px; position:absolute; top:15px; cursor:default;">
                    很抱歉，程序猿正在日以继夜的开发此功能，本程序将会在以后的版本中持续完善！</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">朕已阅</button>
            </div>
        </div>
    </div>
</div>
<!--右键菜单列表-->
<div id="rightClickMenu">
    <ul class="list-group rightClickMenuList">
        <li class="list-group-item disabled">欢迎访问异清轩博客</li>
        <li class="list-group-item"><span>IP：</span>172.16.10.129</li>
        <li class="list-group-item"><span>地址：</span>河南省郑州市</li>
        <li class="list-group-item"><span>系统：</span>Windows10</li>
        <li class="list-group-item"><span>浏览器：</span>Chrome47</li>
    </ul>
</div>
<!--用于接收总页数-->
<input id="pageCount" type="hidden" th:value="${pageCount}">
<input id="page" type="hidden" th:value="${page}">
<script src="js/bootstrap.min.js"></script>
<script src="js/admin-scripts.js"></script>
<script type="text/javascript">
    // var defaults = {
    //     totalData: 0,			//数据总条数
    //     showData: 0,				//每页显示的条数
    //     pageCount: 9,			//总页数,默认为9
    //     current: 1,				//当前第几页
    //     prevCls: 'prev',		//上一页class
    //     nextCls: 'next',		//下一页class
    //     prevContent: '上一页',	//上一页内容
    //     nextContent: '下一页',	//下一页内容
    //     activeCls: 'active',		//当前页选中状态
    //     coping: false,			//首页和尾页
    //     homePage: '首页',			//首页节点内容
    //     endPage: '末页',				//尾页节点内容
    //     count: 3,				//当前页前后分页个数
    //     jump: false,				//跳转到指定页数
    //     jumpIptCls: 'jump-ipt',	//文本框内容
    //     jumpBtnCls: 'jump-btn',	//跳转按钮
    //     jumpBtn: '跳转',			//跳转按钮文本
    //     callback: function (currPageNmu) {
    //     }	//回调(参数：当前页码)
    // };
    $(function () {
        $("#p3").pagination({
            pageCount: document.getElementById("pageCount").value,
            current: document.getElementById("page").value,
            showData: 15,
            coping: true,
            homePage: '首页',
            endPage: '末页',
            prevContent: '上页',
            nextContent: '下页',
            callback: function (api) {
                console.log(api.getCurrent());
                var page = api.getCurrent() - 1;
                window.location.href = "/geekdaily/webArticle?page="+page;
            }
        });
    });
</script>
<script>
    //是否确认删除
    function deleteArticle(article_id){
        if (window.confirm("是否确认删除该文章？")) {
            $.ajax({
                type: "POST",
                url: "/geekdaily/deleteArticle",
                data: {"articleId": article_id},
                cache: false, //不缓存此页面
                success: function (data) {
                    if(data.code === 0){
                        alert(data.data);
                        window.location.reload();
                    }else {
                        window.alert(data.msg);
                    }
                },error:function (XMLHttpRequest) {
                    window.alert("错误信息:" + XMLHttpRequest.responseText);
                }
            });
        }
    }
    //修改编辑文章
    function editArticle(article_id) {
        window.location.href = "/geekdaily/webUpdateArticle?articleId="+article_id;
    }
    //审核文章
    function reviewArticle(article_id) {
        var is_pass = window.confirm("是否审核通过？");
        var token = getCookie("geek_token");
        $.ajax({
            type: "POST",
            headers: {
                'Authorization': token
            },
            url: "/geekdaily/reviewArticle",
            data: {
                "articleId": article_id,
                "isPass": is_pass
            },
            cache: false, //不缓存此页面
            success: function (data) {
                if(data.code === 0){
                    alert(data.data);
                    window.location.reload();
                }else {
                    window.alert(data.msg);
                }
            }, error:function (XMLHttpRequest) {
                window.alert("错误信息:" + XMLHttpRequest.responseText); //获取的信息即是异常中的Message
            }
        });
    }
    //获取cookie的值
    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg))
            return unescape(arr[2]);
        else
            return null;
    }
</script>
</body>
</html>
